#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

//要考虑a==0的情况
LL js(LL a, LL b, LL c, LL y) { return -(b * y + c) / a; }

int main() {
  LL a, b, c, xx1, xx2, yy1, yy2; // 慎用  x1, y1, x2,y2做变量名
  cin >> a >> b >> c >> xx1 >> xx2 >> yy1 >> yy2;
  LL k1 = js(a, b, c, yy1);
  LL k2 = js(a, b, c, yy2);
  if (k1 > k2)
    swap(k1, k2);
  LL L = max(xx1, k1);
  LL R = min(xx2, k2);
  if (R >= L)
    cout << R - L + 1;
  else
    cout << 0;

  return 0;
}